package com.leo;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName ColorDemo
 * @Description
 * @Author wangss
 * @date 2020.07.01 11:26
 * @Version 1.0
 */
public class ColorDemo extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {

        AnchorPane an = new AnchorPane();

        GridPane gridPane = new GridPane();
        gridPane.setHgap(10d);
        gridPane.setVgap(10d);

        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                Rectangle rec = new Rectangle(150, 150);
                rec.setFill(Paint.valueOf("#EDEDED"));
                gridPane.add(rec, j, i);
            }
        }

        List<Color> list = new ArrayList<>();
        list.add(Color.valueOf("#EE6AA7"));
        list.add(Color.valueOf("#EE6AA755"));
        list.add(Color.valueOf("0x6AA7"));
        list.add(Color.BLUE);
        list.add(Color.BLUE.darker());
        list.add(Color.DARKBLUE);
        list.add(new Color(140 / 255, 39 / 255, 62 / 255, 0.5));
        list.add(Color.rgb(140, 39, 69, 0.5));
        list.add(Color.hsb(180, 1, 1, 0.5));
        list.add(Color.rgb(140, 39, 69, 0.5).brighter());

        for (int i = 0; i < list.size(); i++) {
            Rectangle rec = (Rectangle) gridPane.getChildren().get(i);
            rec.setFill(list.get(i));
        }

        an.getChildren().addAll(gridPane);

        Scene scene = new Scene(an);
        primaryStage.setScene(scene);
        primaryStage.setHeight(1000d);
        primaryStage.setWidth(1000d);
        primaryStage.setAlwaysOnTop(true);
        primaryStage.show();

    }
}
